fix(web): bypass xterm for global terminal shortcuts#1580
Open
AriajSarkar wants to merge 7 commits intopingdotgg:mainfrom
Open
fix(web): bypass xterm for global terminal shortcuts#1580AriajSarkar wants to merge 7 commits intopingdotgg:mainfrom
AriajSarkar wants to merge 7 commits intopingdotgg:mainfrom
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Changed
keybindingsstate down fromChatView.tsxintoThreadTerminalDrawer.tsx.attachCustomKeyEventHandleron the xterm.js instance to explicitly pass the shortcutcontext: { terminalFocus: true, terminalOpen: true }.falseon global shortcut matches (terminal.toggle,terminal.new,terminal.split,terminal.close,diff.toggle) to bypass xterm input capture.Why
When the terminal was focused,
xterm.jseagerly captured shortcut combinations (e.g., interceptingCtrl+Jas an0x0ALine Feed, orCtrl+Nas^N).This prevented the global application shortcut listeners in
ChatView.tsxfrom ever receiving these specific keystrokes. By explicitly whitelisting these application-level combinations in the custom event handler and providing the correctwhencontext, xterm safely ignores them and allows thekeydownevent to bubble up properly.Checklist
Note
Medium Risk
Changes keyboard event handling when the embedded terminal is focused, which can subtly affect shortcut behavior and terminal input capture. Risk is contained to the web terminal drawer but could regress expected keystrokes if shortcut matching/context is wrong.
Overview
When an
xterm.jsterminal is focused, app-level shortcuts (terminal toggle/split/new/close anddiff.toggle) are now allowed to bubble up instead of being consumed as terminal input.This is done by plumbing resolved
keybindingsfromChatViewintoThreadTerminalDrawer/TerminalViewportand updatingattachCustomKeyEventHandlerto detect those shortcuts (withcontext: { terminalFocus: true, terminalOpen: true }) and returnfalse, while keeping existing in-terminal navigation/clear handling intact.Written by Cursor Bugbot for commit dc9ac52. This will update automatically on new commits. Configure here.
Note
Bypass xterm key handling for global terminal shortcuts when terminal is focused
keybindingsprop toTerminalViewport(viaThreadTerminalDrawer) so resolved keybindings flow fromChatViewdown to the xterm instance.attachCustomKeyEventHandler, key events matching toggle, split, new-tab, close, or diff shortcuts now returnfalse, preventing xterm from consuming them and allowing higher-level handlers to fire.Macroscope summarized dc9ac52.